﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter7.Section3
{
    public class Example03
    {
        public Example03()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double[]> Phi
                = new V.Function.ToLastType<double[], double[]>(func);
            V.Surface s = new V.Surface(Phi);
            double[] at = { 1.0, 0.0 };
            V.TangentVectorOnSurface tv
                = new V.TangentVectorOnSurface(s,at);
            tv.Compute();
            V.Vector res = tv.Result[0] % tv.Result[1];
            result += res[0].ToString() + "\r\n";
            result += res[1].ToString() + "\r\n";
            result += res[2].ToString() + "\r\n";
        }
        private double[] func(double[] u)
        {
            double[] x = new double[3];
            x[0] = u[0] * Math.Cos(u[1]);
            x[1] = u[0] * Math.Sin(u[1]);
            x[2] = u[0] * u[0] + u[1] * u[1];
            return x;
        }
    }
}
/*
-1.9999999999999
0
0.999999999999923
*/